<?php
namespace app\common\model;

use app\dlc\common\helpers\HtmlHelper;
use think\Db;
use think\Model;

class CaseItem extends Model
{

    static $typeList = [1=>'采集列表页',2=>'采集文章页'];
    static $ruleTypeList = [1=>'简单',2=>'高级'];


    public function cases(){
        return $this->hasOne('Cases','id','cases_id');
    }

    public function caseItemListUrl(){
        return $this->hasMany('CaseItemListUrl','case_item_id','id');
    }
    public function article(){
        return $this->hasMany('Article','case_item_id','id');
    }

    public function getPciAttr($value,$data){
        $res = Db::name('case_item')->where(['id'=>$data['pid']])->find();
        return HtmlHelper::addA("/dlc/case_item/index/id/".$res['id'],$res['name']);
    }
    public function getCciAttr($value,$data){
        $res = Db::name('case_item')->where(['pid'=>$data['id']])->find();
        return HtmlHelper::addA("/dlc/case_item/index/type_id/2/id/".$res['id'],$res['name']);
    }
}